package jiChengHeDuoTai.jiChengHeDuoTai2.demo5;

public class test {
    public static void main1(String[] args) {
        Dog dog=new Dog("旺财",10);
        dog.bark();

        System.out.println("======");
        Animal animal=new Dog("旺财",10);

        dog.bark();//向上转型父类不能直接用到子类
        animal.eat();//在调用的时候方法重写,打印出来的是dog里面的eat方法
    }

    public static void func(Animal animal){

    }

    public static Animal func2(){
        Dog dog=new Dog("旺财",11);
        return dog;
    }

    public static void main(String[] args) {
        Animal animal=func2();
        Animal animal1=new Dog("旺财",10);
        animal1.eat();
        Dog dog=new Dog("旺财",10);
        Animal animal2=dog;
        //func(dog);
    }
}
